#ifndef QCODEPLPGENERATOR_H
#define QCODEPLPGENERATOR_H

#include <QWidget>
#include "ui_qcodeplpgenerator.h"
#include "qexppart.h"
#include <QCompleter>
#include "qobjectpool.h"
#include "qplpsupplier.h"

class QCodePLPGenerator : public QWidget
{
  Q_OBJECT

public:
  QCodePLPGenerator(QEXPPart* part,const QStringList& plp,const QStringList& manu,const QStringList& cat,const QStringList& cat2,const QStringList& cat3,const QStringList& cat4,const QStringList& suppliers,QWidget *parent = 0);
  ~QCodePLPGenerator();
  QStringList generateLines() const;

public slots:
  void generatePlp();
  void plpModified();
  void deleteSupplier();
  void addSupplier();
  void addPLP();
  void modifyPLP();

signals:
  void addPLPValid();
  void modifyPLPValid();
private:
  void definePackage();
  void setCat(QString cat1 = QString(),QString cat2 = QString(), QString cat3 = QString(),QString cat4 = QString());
  bool isCMS(const QString& package) const;
  void reset();
  QString unknown(const QString& text = QString()){ if(text.isEmpty()) return ""; else return text; }
  void checkAndEdit(QComboBox* combo,const QString& text);
  QString rawToFormated(QString) const;
  QString formatedToRaw(QString) const;
  QString voidCat(const QString&);  
  void resetSupplier();
  void refreshSupplier();
  
  Ui::QCodePLPGeneratorClass ui;

  QEXPPart* m_part;
  QStringList m_existingSuppliers;
  QObjectPool<QPLPSupplier>* m_pool;
  bool m_generated;
};

#endif // QCODEPLPGENERATOR_H
